package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;

public class Overview {
	private WindowsApplication windowsApp;
	private JPanel pnlOverview;
	
	public Overview(){
		initialize();
	}
	public Overview(WindowsApplication windowsApp){
		this.windowsApp = windowsApp;
		initialize();
	}
	private void initialize(){
		pnlOverview = new JPanel();
		pnlOverview.setBounds(0, 0, 800, 600);
		pnlOverview.setLayout(null);
		
		JButton btnAccount = new JButton("Account");
		btnAccount.setBounds(405, 75, 143, 107);
		btnAccount.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				windowsApp.getFrame().setContentPane(new Account(windowsApp).getPanel());
			}
		});
		pnlOverview.add(btnAccount);
		
		JButton btnDevicesList = new JButton("Devices List");
		btnDevicesList.setBounds(100, 75, 143, 107);
		btnDevicesList.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				windowsApp.getFrame().setContentPane(new DeviceList(windowsApp).getPanel());
			}
		});
		pnlOverview.add(btnDevicesList);
		
		JButton btnDevicesMap = new JButton("Devices Map");
		btnDevicesMap.setBounds(252, 75, 143, 107);
		btnDevicesMap.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				windowsApp.getFrame().setContentPane(new DeviceMap(windowsApp).getPanel());
			}
		});
		pnlOverview.add(btnDevicesMap);
		
		JButton btnPairing = new JButton("Pairing");
		btnPairing.setBounds(557, 75, 143, 107);
		btnPairing.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				windowsApp.getFrame().setContentPane(new Pairing(windowsApp).getPanel());
			}
		});
		pnlOverview.add(btnPairing);
		
		JButton btnLogOut = new JButton("Log Out");
		btnLogOut.setBounds(691, 562, 97, 25);
		btnLogOut.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				//log out the user
				windowsApp.setUser(null);
				windowsApp.getFrame().setContentPane(new Login(windowsApp).getPanel());
			}
		});
		pnlOverview.add(btnLogOut);
		
		JButton btnAddDevice = new JButton("Add Device");
		btnAddDevice.setBounds(668, 250, 120, 50);
		btnAddDevice.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				windowsApp.getFrame().setContentPane(new AddDevice(windowsApp).getPanel());
				System.out.println("AddAction");
			}
		});
		pnlOverview.add(btnAddDevice);
		
		JButton btnRemoveDevice = new JButton("Remove Device");
		btnRemoveDevice.setBounds(668, 313, 120, 50);
		btnRemoveDevice.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				System.out.println("RemoveAction");
			}
		});
		pnlOverview.add(btnRemoveDevice);
	}
	
	public JPanel getPanel(){
		return pnlOverview;
	}
}
